package com.slfx.idgen.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.slfx.idgen.server.constants.CommonConstants;
import com.slfx.idgen.server.dto.GuidHolder;
import com.slfx.idgen.server.entity.Guid;
import com.slfx.idgen.server.mapper.GuidMapper;
import com.slfx.idgen.server.service.IGuidService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author slfx
 * @since 2023-01-06
 */
@Service
public class GuidServiceImpl extends ServiceImpl<GuidMapper, Guid> implements IGuidService {

    @Resource
    private GuidMapper guidMapper;

    @Override
    public Long getGuid() {
        GuidHolder guidHolder = new GuidHolder();
        guidHolder.setStub(CommonConstants.STUB);
        int guid = guidMapper.getGuid(guidHolder);
        return guidHolder.getId();
    }

    @Override
    public Long getGuid2() {
        Guid guid = new Guid();
        guid.setStub(CommonConstants.STUB);
        int guid2 = guidMapper.getGuid2(guid);
        return guid.getId();
    }

    @Override
    public Long getGuid3() {
        GuidHolder guidHolder = new GuidHolder();
        guidHolder.setStub(CommonConstants.STUB);
        int guid3 = guidMapper.getGuid3(guidHolder);
        return guidHolder.getId();
    }
}
